package com.robert.autoplayvideo;

import ohos.utils.Parcel;
import ohos.utils.Sequenceable;

import java.io.Serializable;

/**
 * Created by robert on 17/08/03.
 */
public class VideoModel implements Sequenceable {
    private String image_url;
    private String video_url;
    private String name;
    public VideoModel() {
    }
    public VideoModel(String video_url, String image_url, String name) {
        this.video_url = video_url;
        this.image_url = image_url;
        this.name = name;
    }

    public VideoModel(String image_url, String name) {
        this.image_url = image_url;
        this.name = name;
    }

    public String getImage_url() {
        return image_url;
    }

    public void setImage_url(String image_url) {
        this.image_url = image_url;
    }

    public String getVideo_url() {
        return video_url;
    }

    public void setVideo_url(String video_url) {
        this.video_url = video_url;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    @Override
    public boolean marshalling(Parcel out) {
        out.writeString(name);
        return out.writeString(video_url)&& out.writeString(image_url);
    }

    @Override
    public boolean unmarshalling(Parcel in) {
        this.name = in.readString();
        this.video_url = in.readString();
        this.image_url = in.readString();
        return true;
    }
    //序列化对象的内部构造器，必须实现
    public static final Sequenceable.Producer
            PRODUCER = new Sequenceable.Producer
            () {
        public VideoModel createFromParcel(Parcel in) {    //从包裹中获取数据构造对象
            // Initialize an instance first, then do customized unmarshlling.
            VideoModel instance = new VideoModel();
            instance.unmarshalling(in);
            return instance;
        }   //必须实现Producer
    };
}
